/****************************************************************************
 *
 * Copyright (C) 2003-2008 Los Alamos National Security, LLC
 *                         Packet Analytics Corporation
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License Version 2 as
 * published by the Free Software Foundation.  You may not use, modify or
 * distribute this program under any other version of the GNU General
 * Public License.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 *
 ****************************************************************************/
package nfse.result;

import nfse.*;

public class ResultField implements Cloneable {
	public int type = -1;
	public int field = -1;
	public int globalField = -1;
	public int length = -1;
	public int format = -1;
	public String delimiterf = "";
	public String delimiterb = "";
	public String padf = "";
	public String padb = "";
	public String label = "";
	
	public Object clone() {
		ResultField rs = new ResultField();
		rs.field = field;
		rs.length = length;
		rs.format = format;
		rs.delimiterf = delimiterf;
		rs.padf = padf;
		rs.delimiterb = delimiterb;
		rs.label = label;
		rs.type = type;
		return rs;	
	}

	public String toXML() {
		String temp = "<ResultField ";
		if (type != -1) {
			temp += "type=\"" + NetFSE.getTypeName(type) + "\" ";
		}
		if (field != -1) {
			temp += "field=\"" + NetFSE.FIELD_NAMES[globalField] + "\" ";
		}
		if (length != -1) {
			temp += "length=\"" + length + "\" ";
		}
		/*if (format != -1) {
			temp += "format=\"" + NetFSE.REP_NAMES[format] + "\" ";
		}*/
		if (delimiterf.length() > 0) {
			temp += "delimiterf=\"" + delimiterf + "\" ";
		}
		if (padf.length() > 0) {
			temp += "padf=\"" + padf + "\" ";
		}
		if (delimiterb.length() > 0) {
			temp += "delimiterb=\"" + delimiterb + "\" ";
		}
		if (padb.length() > 0) {
			temp += "padb=\"" + padb + "\" ";
		}
		if (label.length() > 0) {
			temp += "label=\"" + label + "\" ";
		}
		temp += "/>";
		return temp;
	}
}
